package com.example.mallproduct.fallback;

import com.example.mallcommon.RestResult;
import com.example.mallproduct.api.domain.Product;
import com.example.mallproduct.feign.ProductFeign;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/** @author Administrator FallBackFactory */
@Component
public class ProductFeignFallbackFactory implements FallbackFactory<ProductFeign> {
  @Override
  public ProductFeign create(Throwable throwable) {
    return new ProductFeign() {
      @Override
      public RestResult<Product> findByPid(Integer pid) {
        throwable.printStackTrace();
        Product product = new Product();
        product.setPid(-1);
        return RestResult.success(product);
      }

      @Override
      public void reduceInventory(Integer pid, int num) {

      }
    };
  }
}
